#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
    int m = 0, n = 0;
    int arr1[1005] = { 0 };
    int arr2[1005] = { 0 };
    scanf("%d%d", &m, &n);
    int i = 0;
    for (i = 0; i < m; i++)
    {
        scanf("%d", &arr1[i]);
    }
    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr2[i]);
    }
    int arr3[2005] = { 0 };
    for (i = 0; i < m; i++)
    {
        arr3[i] = arr1[i];
    }
    for (i = 0; i <m + n; i++)
    {
        arr3[i + m] = arr2[i];
    }
    int cnt = m + n;
    for (i = 0; i < cnt - 1; i++)
    {
        int j = 0;
        for (j = 0; j < cnt-1-i; j++)
        {
            if (arr3[j] > arr3[j+1])
            {
                int temp = arr3[j];
                arr3[j] = arr3[j+1];
                arr3[j+1] = temp;
            }
        }
    }
    for (i = 0; i < m + n; i++)
    {
        printf("%d ", arr3[i]);
    }
    return 0;
}